﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace D3Calc
{
    public partial class EquipmentForm : Form
    {
        public EquipmentForm()
        {
            InitializeComponent();
        }

        public void Init(Equipment equipment)
        {
            this.equipmentUserControl.Min = equipment.Min;
            this.equipmentUserControl.Max = equipment.Max;
            this.equipmentUserControl.Main = equipment.Main;
            this.equipmentUserControl.Crit = equipment.Crit;
            this.equipmentUserControl.Speed = equipment.Speed;
            this.equipmentUserControl.Hurt = equipment.Hurt;
        }

        public void Change(ChangeEquipment changeEquipment, Equipment equipment)
        {
            this.changeEquipment = changeEquipment;
            this.equipment = equipment;
        }

        private void btnSave_Click(object sender, EventArgs e)
        {
            equipment.Min = this.equipmentUserControl.Min;
            equipment.Max = this.equipmentUserControl.Max;
            equipment.Main = this.equipmentUserControl.Main;
            equipment.Crit = this.equipmentUserControl.Crit;
            equipment.Speed = this.equipmentUserControl.Speed;
            equipment.Hurt = this.equipmentUserControl.Hurt;

            changeEquipment();
            this.Close();
        }

        private void chbNew_CheckedChanged(object sender, EventArgs e)
        {
            equipment.UseNew = chbNew.Checked;
            if (chbNew.Checked)
            {
                InitNew(equipment);
            }
            else
            {
                Init(equipment);
            }
        }

        private void InitNew(Equipment equipment)
        {
            this.equipmentUserControl.Min = equipment.NewMin;
            this.equipmentUserControl.Max = equipment.NewMax;
            this.equipmentUserControl.Main = equipment.NewMain;
            this.equipmentUserControl.Crit = equipment.NewCrit;
            this.equipmentUserControl.Speed = equipment.NewSpeed;
            this.equipmentUserControl.Hurt = equipment.NewHurt;
        }

        private ChangeEquipment changeEquipment = null;
        private Equipment equipment = null;
    }
}
